package br.diego.tb.dataconversion;

public class CountOnes
{

    public static Integer count_one(Integer a)
    {
    	int totalOnes = 0;
    	
    	String aAsBinary = Integer.toBinaryString(a);
    	System.out.println(aAsBinary);
    	
    	for(char digit : aAsBinary.toCharArray())
    		totalOnes = totalOnes + Character.getNumericValue(digit);
    	
    	System.out.println(totalOnes);
    	
    	return totalOnes;
    }
}
